{extend name="admin@extend/layui" /}

{block name="head_title"}{/block}

{block name="head_styles"}
<link rel="stylesheet" type="text/css" href="__ROOT__/static/layuiadmin/style/admin.css">
<link rel="stylesheet" type="text/css" href="__ROOT__/static/layuiadmin/style/login.css">
{/block}

{block name="body_content"}
<body>
<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">

    <div class="layadmin-user-login-main">
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <h2>测试后台</h2>
            <p>后台管理系统</p>
        </div>
        <form class="layadmin-user-login-box layadmin-user-login-body layui-form" method="post" action="#" lay-filter="admin-login">
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
                <input type="text" name="username" id="LAY-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input" value="{$remember_user['username']|default=''}">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
                <input type="password" name="password" id="LAY-user-login-password" lay-verify="required" placeholder="密码" class="layui-input" value="{$remember_user['password']|default=''}">
            </div>
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-xs7">
                        <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
                        <input type="text" name="verify_code" id="LAY-user-login-vercode" lay-verify="required" placeholder="图形验证码" class="layui-input">
                    </div>
                    <div class="layui-col-xs5">
                        <div style="margin-left: 10px;">
                            <img src="{:get_url('/admin/Login/getVerifyCodeNum')}" class="layadmin-user-login-codeimg" id="LAY-user-get-vercode" data-verify-code="{:get_url('/admin/Login/getVerifyCodeNum')}">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="margin-bottom: 20px;">
                <input type="checkbox" name="remember" value="1" lay-skin="primary" title="记住密码" {$remember_user['remember']?='checked'}>
                <a href="forget.html" class="layadmin-user-jump-change layadmin-link" style="margin-top: 7px;">忘记密码？</a>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit">登 入</button>
            </div>
        </form>
    </div>

</div>
</body>
{/block}

{block name="body_scripts"}
<script type="text/javascript">
    layui.config({
        base : '__ROOT__/static/layuiadmin/'
    }).extend({
        index : 'lib/logic/login/index' // 后台登录入口
    }).use(['index'],function(){
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;

        // form.val('admin-login',{
        // 	username : "420092586@qq.com",
        // 	password : "123456",
        // 	vercode : "1234",
        // 	remember : "1"
        // });

        form.on('submit(LAY-user-login-submit)',function(ret){
            // console.log(ret);

            $.ajax({
                url : "{:get_url('/admin/Login/signIn')}",
                type : 'post',
                data : $.extend({
                    remember : ret.field['remember']==1?1:0
                },ret.field),
                success : function(ret){
                    if(ret.code == 200){
                        //登入成功的提示与跳转
                        layer.msg('登入成功', {
                            offset: '15px'
                            ,icon: 1
                            ,time: 1000
                        }, function(){
                            location.href = "{:get_url('/admin/index/index')}"; //后台主页
                        });
                    }else{
                        $('[data-verify-code]').click();
                        layer.msg(ret.msg,{icon:5});
                    }
                }
            });

            return false;
        });
    });
</script>
{/block}